package cn.stylefeng.guns.modular.system.controller;


import cn.stylefeng.guns.base.auth.context.LoginContextHolder;
import cn.stylefeng.guns.modular.system.enums.ResultEnum;
import cn.stylefeng.guns.modular.system.service.AppPersonalCenterService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

@Controller
@RequestMapping("/appPersonalCenter")
public class AppPersonalCenterController {

    private final static Logger log = LoggerFactory.getLogger(AppPersonalCenterController.class);

    private static final String SECCESS = "SECCESS";

    private String PREFIX = "/modular/system/appPersonalCenter/";

    @Autowired
    private AppPersonalCenterService appPersonalCenterService;

    /**
     * 跳转到主页面
     *
     * @author mwb
     * @Date 2019-06-20
     */
    @RequestMapping("")
    public String index(Model model) {
        Long userId = LoginContextHolder.getContext().getUserId();
        log.info("代理人id是 "+userId);
        Assert.isTrue(!ObjectUtils.isEmpty(userId), ResultEnum.PROXYID_DOES_NOT_EXIST.getMessage());
        Map<String,Object> maps=appPersonalCenterService.selectUserInfo(userId);
        model.addAttribute("item",maps);
        return PREFIX + "appPersonalCenter.html";
    }

    /**
     * 跳转添加页面
     *
     * @author mwb
     * @Date 2019-06-20
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "appPersonal_add.html";
    }

}
